package view
{
	import flash.events.Event;
	
	import model.Enseignant;
	import model.proxy.EdtProxy;
	import model.proxy.LoginProxy;
	
	import mx.collections.ArrayCollection;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	import view.components.EdtEnseignantPanel;
	
	public class EdtEnseignantPanelMediator extends Mediator implements IMediator 
	{ 
		
		public static const NAME : String = 'EdtEnseignantPanelMediator'; 
			
		/** 
		 * Constructor 
		 * Listen event of the component to send notification 
		 */ 
		 public function EdtEnseignantPanelMediator(viewComponent : EdtEnseignantPanel) 
		 { 
		 	super(NAME, viewComponent); 
		 	viewComponent.addEventListener(EdtEnseignantPanel.OBTENIR_LISTE_SEANCES_ENSEIGNANT, obtenirListeSeancesEnseignantNotification);
		 }
			
		 private function obtenirListeSeancesEnseignantNotification(event : Event=null):void
		 { 
		 	 var enseignant:Enseignant = LoginProxy.user.aEnseignant;
			 sendNotification(EdtEnseignantPanel.OBTENIR_LISTE_SEANCES_ENSEIGNANT, enseignant);
		 }
		 
		 override public function listNotificationInterests():Array 
		 { 
			 return [ EdtProxy.LISTE_SEANCES_ENSEIGNANT_OBTENUE ]; 
		 } 
			 
	
		 override public function handleNotification(note : INotification):void 
		 { 
			 switch (note.getName()) 
			 { 
			 	case EdtProxy.LISTE_SEANCES_ENSEIGNANT_OBTENUE:
			 	{
			 		edtEnseignantPanel.items = new ArrayCollection(note.getBody() as Array);
			 		break;
			 	}
			 	default:
			 	break;
		 	} 
		 }
		
		
		 private function get edtEnseignantPanel():EdtEnseignantPanel
		 { 
		 	return viewComponent as EdtEnseignantPanel; 
		 }
	}
}